Typescript does not complain about lack of import

Content foo.ts:

let a: Person = new Person();

Content bar.ts:

class Person {}

The tsconfig.json file contains the set of default values ​​created tsc --init.

I am using typescript version 2.6.2.

The above code simply compiles without errors in regards Personthat are not defined. If I rename Personto Personsfoo.ts, then it causes an error saying cannot find name 'Persons'. Thus, it seems to automatically import this file.

Also note that I do not export the class Personto bar.ts. If I add an export statement, then everything will behave as it should - I get an error message cannot find name 'Person'.

Does anyone know what is going on here? Is this a user error?

Edit:

, , node.js. typescript, ?

+4
2

--isolatedModules , .ts . foo.ts bar.ts, 1 import export, Person .

, , : https://github.com/Microsoft/TypeScript/issues/18232#issuecomment-359200157

0

bar.ts , . , Person, , . , TypeScript .

+1

Source: https://habr.com/ru/post/1692317/


All Articles