Basic question: Is it possible to type-check only import
s?
I do want to know
TS: property 'id' does not exist on type 'Stripe.customer'
(for example)- but not on my own objects, like
property 'prop1' does not exist on type '{}'
Background
I'm working on a Javascript project, and I'd like to use Typescript for added intellisense with imported libraries, while otherwise writing in JS, so I've changed my
.js
file to.ts
during development. († see bottom)In the Javascript project, lots of objects are initialized as
let x = {}
and then properties are later added asx.prop1 = value1
.TSLint then warns me,
property 'prop1' does not exist on type 'x'
.
I would like to get this warning only on imports.
For instance, if I
import * as stripe from 'stripe'
, then it's helpful to get the warningproperty 'id' doest not exist on type 'customer'
.Following this thread, property does not exists on type '{}' , I can achieve this manually on a per-object basis by converting
x.prop1
tox['prop1']
.I've also experimented with inline comments to disable various TSLint rules, but the warnings are coming from the Typescript language features in VSCode, not TSLint.
However, to restate the question more precisely: Is there directive or config option that would allow me to add properties to objects defined in my own code without warning, while still warning/type-checking imported libraries?
† If there's a alternative, less janky way to get intellisense on imported libraries in Javascript, I'm all ears!