首页 > 其他分享 >TypeScript declare type vs type in .d.ts file All In One

TypeScript declare type vs type in .d.ts file All In One

时间:2023-02-10 23:11:05浏览次数:42  
标签:TypeScript string url ts API test type declare

TypeScript declare type vs type in .d.ts file All In One

declare type vs type

// declare type alias
declare type API = string;

//  type alias
type API = string;

image

demos

  1. test.ts => test.d.ts
// declare type
declare type API = string;

function test(url: API){
  console.log(`✅ url =`, url);
  return url;
}

export default test;

  1. test.ts => test.d.ts
// type
type API = string;

function test(url: API){
  console.log(`✅ url =`, url);
  return url;
}

export default test;

输入 输出 截图
declare type API = string; declare type API = string; image
type API = string; type API = string; image

(

标签:TypeScript,string,url,ts,API,test,type,declare
From: https://www.cnblogs.com/xgqfrms/p/17110621.html

相关文章