Pardon a question here: Will ES6 Code ‘just Run’ under TypeScript? I think the answer is yes for ES5, but I don’t know about ES6. Thanks.
Pardon a question here: Will ES6 Code ‘just Run’ under TypeScript? I think the answer is yes for ES5, but I don’t know about ES6. Thanks.
If your question is whether you can just change the file extension of a working ES6 file to .ts without Typescript complaining then answer is 'yes', you should be able to do that no problem.
Edit: of course there is little sense in doing nothing more than that, but it is a good starting point for decorating existing Javascript with TS features.
That isn't wrong behavior on TS's part, just getting started with TypeScript is very configuration heavy, particularly for targeting browsers.
They specifically said they won't provide polyfills and they Will continue to typecheck even if your target does not support the standard function.
An example would be that classes that don't explicitly declare their fields will throw a type error when their fields are mutated (eg. `this.foo = 123`).
The compiler will emit JS anyway.
class Foo {
foo;
constructor() {
this.foo = 42
}
}
Will be both valid ES2019 or ES2020 and TypeScript.TS is ES6 + types (and other things).