deno_registry2 icon indicating copy to clipboard operation
deno_registry2 copied to clipboard

Specifying path to type definitions

Open SheetJSDev opened this issue 3 years ago • 0 comments

import * as XLSX from 'https://deno.land/x/[email protected]+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/[email protected]+deno/types/index.d.ts"
import * as XLSX from 'https://deno.land/x/[email protected]+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?

SheetJSDev avatar Feb 12 '22 07:02 SheetJSDev