Loading
dinht
This is a live streamed presentation. You will automatically follow the presenter and see the slide they're currently on.
Phuc Tran
Developer @ Nord Pool
class LeClass<T> implements ILeInterface {
readonly apiPath = "leApiPath";
constructor(
private leService: ILeService;
)
getAll(refreshCache: boolean = false): Promise<T[]> {
this.leService.get<T>(this.apiPath);
}
}
Catch errors sooner!
Natural primitive types!
Navigating code
(Code editor's) Quick actions
Generics!
Small overhead?
Manually
With npm
With static typing npm packages
"declaration": true
Or publish to @type org on npm
"main": "./src/index.js",
"types": "./src/index.d.ts"
also apply to js package in general
if you're lucky
and if you're not so lucky....
and when you need
to debug
an external package...
to TS source code, we need
'We can't live like this'
java, c#, python pkg can be decompiled on the spot!
'Just go to the repo and look'
'You should be able to read ugly js codes'
"main": "./src/index.ts",
"types": "./src/index.ts"
ERROR in ./~/@hkijs/angular-2-common/src/index.ts
Module parse failed:
/c/@hkijs/node_modules/@hkijs/angular-2-common/src/index.ts
Unexpected character '@' (58:0)
You may need an appropriate loader to handle this file type.
SyntaxError: Unexpected character '@' (58:0)
Solution
loaders: [
{ test: /\.ts$/, loaders: ["ts"], exclude: /node_modules/ },
loaders: [
{ test: /\.ts$/, loaders: ["ts"]},
to this
Solution with tsconfig.json
"include": [
"node_modules/@hkijs/angular-2-common/**/*",
"..."
]
Subsequent variable declarations must have the same type...
.d.ts(83,5): error TS2300: Duplicate identifier 'A'.
.d.ts(84,5): error TS2300: Duplicate identifier 'B'.
exhibit 1, 'Go to definition'
'Hei Phuc, your pkg doesn't work'
'Hei dumba**, you missed exception handling here'
became
Phuc Tran
Developer @ Nord Pool