TypeScript hiện đại: từ cơ bản đến nâng cao (TS 6 & 7)›9. Module, declaration file và tsconfigQuiz: Module và tsconfigKiểm tra hiểu biết về module, declaration file và tsconfig.Question 1.`import type { User } from "./user.ts";``import { type User } from "./user.ts";``import { User } from "./user.ts";`Không dòng nàoQuestion 2.`"module": "commonjs"``"module": "nodenext"``"module": "esnext", "moduleResolution": "bundler"``"module": "amd"`Question 3.Select all correct answers.`"baseUrl"``"moduleResolution": "node"``"target": "es5"``"noUncheckedIndexedAccess"`Question 4.`number``1``number | undefined``unknown`Question 5.`const s: S = {};``const s: S = { theme: "dark" };``const s: S = { theme: undefined };`Không dòng nàoQuestion 6.Bật `skipLibCheck`Viết `declare module "legacy-lib" { ... }` trong một file `.d.ts`Đổi tên file thành `.mts`Thêm `legacy-lib` vào `paths`Question 7.Select all correct answers.Chỉ giúp TypeScript tìm file, không đổi đường dẫn trong JavaScript đầu raDùng được mà không cần `baseUrl` (đường dẫn tính từ thư mục chứa tsconfig)Tự động làm Node.js hiểu alias `@/...` lúc chạyVới Node, có thể dùng `"imports"` (subpath `#`) trong package.json để alias chạy được thậtQuestion 8.TypeScript báo lỗi lúc biên dịchNode tự ném lỗi khi khởi động`process.env.DATABASE_URL` là `undefined` lúc chạy dù kiểu nói là `string`Giá trị mặc định là chuỗi rỗngQuestion 9.Vì TS 6 có bugVì các kiểm tra như `strictNullChecks`, `noImplicitAny` được bật nếu tsconfig không ghi rõ `strict`Vì TS 6 bỏ hỗ trợ JavaScriptVì `strict` bật `noUncheckedIndexedAccess`Check Mark as completed← PreviousNext →Comments
Comments