denoland / website_feedback

For reporting issues & suggestions for deno.com and deno.land
9 stars 1 forks source link

Specifying path to type definitions #6

Open SheetJSDev opened 2 years ago

SheetJSDev commented 2 years ago
import * as XLSX from 'https://deno.land/x/sheetjs@v0.18.0+deno/xlsx.mjs';

const wb = XLSX.utils.book_new(); 

Error message:

error: TS2339 [ERROR]: Property 'book_new' does not exist on type '{ encode_col: (col: any) => string; encode_row: (row: any) => string; encode_cell: (cell: any) => string; encode_range: (cs: any, ce: any) => any; decode_col: (colstr: any) => number; decode_row: (rowstr: any) => number; ... 20 more ...; sheet_to_row_object_array: (sheet: any, opts: any) => {}[]; }'.

It works when manually specifying a type file. In this case, it is types/index.d.ts:

// @deno-types="https://deno.land/x/sheetjs@v0.18.0+deno/types/index.d.ts"
import * as XLSX from 'https://deno.land/x/sheetjs@v0.18.0+deno/xlsx.mjs';

const wb = XLSX.utils.book_new(); 

This works with traditional node / tsc workflows because of the package.json types field:

    "types": "types/index.d.ts",

What settings are needed for the registry to serve the types automatically?